//
//  ETVCrentLimitTableViewCell.m
//  Jyxt
//
//  Created by 宫璞 on 2017/9/11.
//  Copyright © 2017年 DaLian Rental Housing Management. All rights reserved.
//

#import "ETVCrentLimitTableViewCell.h"
#import "Hcolors.h"
@implementation ETVCrentLimitTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.rentLimitLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, 80, 24)];
        self.rentLimitLabel.textColor = COLOR_NEW_153;
        self.rentLimitLabel.text = @"租赁期限";
        self.rentLimitLabel.font = [UIFont systemFontOfSize:15];
        [self addSubview:self.rentLimitLabel];
        
        self.detailRentLimitLabel = [[UILabel alloc]initWithFrame:CGRectMake(self.rentLimitLabel.frame.origin.x + self.rentLimitLabel.frame.size.width + 10, 10, 80, 24)];
        self.detailRentLimitLabel.font = [UIFont systemFontOfSize:15];
        [self addSubview:self.detailRentLimitLabel];
        
        self.zeroLineLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 44, [UIScreen mainScreen].bounds.size.width, 0.5)];
        self.zeroLineLabel.backgroundColor = COLOR_NEW_237;
        [self addSubview:self.zeroLineLabel];
        
        self.startTimeLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, self.zeroLineLabel.frame.origin.y + self.zeroLineLabel.frame.size.height  +10, 80, 24)];
        self.startTimeLabel.text = @"起始时间";
        self.startTimeLabel.textColor = COLOR_NEW_153;
        self.startTimeLabel.font = [UIFont systemFontOfSize:15];
        [self addSubview:self.startTimeLabel];
        
        self.detailStartTimeLabel = [[UILabel alloc]initWithFrame:CGRectMake(self.startTimeLabel.frame.origin.x + self.startTimeLabel.frame.size.width + 10, self.zeroLineLabel.frame.origin.y + self.zeroLineLabel.frame.size.height  +10, [UIScreen mainScreen].bounds.size.width - 10 - 10 - 80, 24)];
        self.detailStartTimeLabel.font = [UIFont systemFontOfSize:15];
        [self addSubview:self.detailStartTimeLabel];
        
        self.lineOneLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 88.5, [UIScreen mainScreen].bounds.size.width, 0.5)];
        self.lineOneLabel.backgroundColor = COLOR_NEW_237;
        [self addSubview:self.lineOneLabel];
        
        self.endTimeLable = [[UILabel alloc]initWithFrame:CGRectMake(10, self.lineOneLabel.frame.origin.y + self.lineOneLabel.frame.size.height + 10, 80, 24)];
        self.endTimeLable.text = @"终止时间";
        self.endTimeLable.textColor = COLOR_NEW_153;
        self.endTimeLable.font = [UIFont systemFontOfSize:15];
        [self addSubview:self.endTimeLable];
        
        self.detailEndTimeLabel = [[UILabel alloc]initWithFrame:CGRectMake(self.endTimeLable.frame.origin.x + self.endTimeLable.frame.size.width + 10, self.lineOneLabel.frame.origin.y + self.lineOneLabel.frame.size.height + 10, 100, 24)];
        self.detailEndTimeLabel.font = [UIFont systemFontOfSize:15];
        [self addSubview:self.detailEndTimeLabel];
    }
    return self;
}


- (void)setContent:(McontractDetailModel *)rentlimitSection{
    NSString *strStart = rentlimitSection.startTime;//时间戳
    NSTimeInterval time = [strStart doubleValue];
    NSDate *detaildate = [NSDate dateWithTimeIntervalSince1970:time];
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"yyyy/MM/dd"];
    NSString *currentDateStr = [dateFormatter stringFromDate: detaildate];
    self.detailStartTimeLabel.text= currentDateStr;

    self.detailRentLimitLabel.text = rentlimitSection.date;
//    self.detailEndTimeLabel.text = rentlimitSection.endTime;
    NSString *strEnd = rentlimitSection.endTime;//时间戳
    NSTimeInterval timeEnd = [strEnd doubleValue];
    NSDate *detaildateEnd = [NSDate dateWithTimeIntervalSince1970:timeEnd];
    NSDateFormatter *dateFormatterEnd = [[NSDateFormatter alloc] init];
    [dateFormatterEnd setDateFormat:@"yyyy/MM/dd"];
    NSString *currentDateStrEnd = [dateFormatterEnd stringFromDate: detaildateEnd];
    self.detailEndTimeLabel.text= currentDateStrEnd;
}



@end
